<?php 	session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hand Analyser</title>
<link REL="SHORTCUT ICON" HREF="http://ron.motionlabclients.co.uk/pkrHands/favicon.ico">

<style type="text/css">
	.card{width: 71px; height: 96px; overflow: hidden; background: #FFF url('./views/themes/default/images/StandardDeck.gif') no-repeat -216px -388px; text-indent: -1000px; float: left; margin-right: 5px;}
	
	.hand .action{display: none;}
	
	.valueAc{background-position: 0 0;}
	.value2c{background-position: -72px 0;}
	.value3c{background-position: -144px 0;}
	.value4c{background-position: -216px 0;}
	.value5c{background-position: -288px 0;}
	.value6c{background-position: -360px 0;}
	.value7c{background-position: -432px 0;}
	.value8c{background-position: -504px 0;}
	.value9c{background-position: -576px 0;}
	.valueTc{background-position: -648px 0;}
	.valueJc{background-position: -720px 0;}
	.valueQc{background-position: -792px 0;}
	.valueKc{background-position: -864px 0;}
	
	.valueAd{background-position: 0 -97px;}
	.value2d{background-position: -72px -97px;}
	.value3d{background-position: -144px -97px;}
	.value4d{background-position: -216px -97px;}
	.value5d{background-position: -288px -97px;}
	.value6d{background-position: -360px -97px;}
	.value7d{background-position: -432px -97px;}
	.value8d{background-position: -504px -97px;}
	.value9d{background-position: -576px -97px;}
	.valueTd{background-position: -648px -97px;}
	.valueJd{background-position: -720px -97px;}
	.valueQd{background-position: -792px -97px;}
	.valueKd{background-position: -864px -97px;}

	.valueAh{background-position: 0 -194px;}
	.value2h{background-position: -72px -194px;}
	.value3h{background-position: -144px -194px;}
	.value4h{background-position: -216px -194px;}
	.value5h{background-position: -288px -194px;}
	.value6h{background-position: -360px -194px;}
	.value7h{background-position: -432px -194px;}
	.value8h{background-position: -504px -194px;}
	.value9h{background-position: -576px -194px;}
	.valueTh{background-position: -648px -194px;}
	.valueJh{background-position: -720px -194px;}
	.valueQh{background-position: -792px -194px;}
	.valueKh{background-position: -864px -194px;}
	
	.valueAs{background-position: 0 -291px;}
	.value2s{background-position: -72px -291px;}
	.value3s{background-position: -144px -291px;}
	.value4s{background-position: -216px -291px;}
	.value5s{background-position: -288px -291px;}
	.value6s{background-position: -360px -291px;}
	.value7s{background-position: -432px -291px;}
	.value8s{background-position: -504px -291px;}
	.value9s{background-position: -576px -291px;}
	.valueTs{background-position: -648px -291px;}
	.valueJs{background-position: -720px -291px;}
	.valueQs{background-position: -792px -291px;}
	.valueKs{background-position: -864px -291px;}
	
	.stats{margin-bottom: 10px;}
	
	#dataWrapper{width: 1150px;}
	#informationPane{width: 70%; padding: 10px; float: left; border: 1px solid black; min-height: 450px;}
	#informationPane .streetCards{display: block;}
	#informationPane .streetName{clear: both; margin-top: 10px;}
	.handHistory{float: left;}
	.hand{width: 220px; padding: 10px 0 10px 10px}
	.hand.selected{background-color: #EEEEEE; border: 1px solid black;}
	.hand .PreFlop,.hand .Flop,.hand .Turn,.hand .River{display:none;}
	
	#handNav{width: 1145px}
	#handNav a { border: 1px solid #ccc; background: #fc0; 
	text-decoration: none; margin: 0 5px; padding: 3px 5px; display:block; float:left }
	#handNav a.activeSlide { background: #ea0 }
	#handNav a:focus { outline: none; }

</style>
<link rel="stylesheet" type="text/css" href="views/themes/default/css/jquery-ui/theme/ui.all.css">
<script src="http://www.google.com/jsapi?key=ABQIAAAAdbZzzW6_p1p1VZBkc9LxYhQRazRz_hx3HcUsGZHFt1z3iV6UMhQyhI0iG0NiX4N6bc6haD8-jdJPyg" type="text/javascript"></script>
<script type="text/javascript">
		var initJquery = function(){google.load("jquery", "1.2");
		google.load("jqueryui", "1.5");
		} ; 
		try {initJquery(); } catch (e){ setTimeout("1000" , initJquery ); }
</script>
<script src="http://www.google.com/jsapi?key=ABQIAAAAdbZzzW6_p1p1VZBkc9LxYhQRazRz_hx3HcUsGZHFt1z3iV6UMhQyhI0iG0NiX4N6bc6haD8-jdJPyg" type="text/javascript"></script>
<script src="app/webroot/js/jquery-cycle.js" type="text/javascript"></script>
<script src="app/webroot/js/jquery-easing.js" type="text/javascript"></script>

<script>
	function showHandData($handID){
			//$handID = $(this).parents('.hand').attr('id');
			$('.hand').removeClass('selected');
			$('#'+$handID).addClass('selected');
			$preFlop = $('#'+$handID+' .PreFlop').html();
			$Flop = $('#'+$handID+' .Flop').html();
			$Turn = $('#'+$handID+' .Turn').html();
			$River = $('#'+$handID+' .River').html();
			$Showdown = $('#'+$handID+' .pot').html();
			$playerProfiles = $('#'+$handID+' .players').html();
			
			$('#informationPane').html('<ul><li><a href="#PreFlop"><span>Pre Flop</span></a></li><li><a href="#Flop"><span>Flop</span></a></li><li><a href="#Turn"><span>Turn</span></a></li><li><a href="#River"><span>River</span></a></li><li><a href="#Showdown"><span>Result</span></a></li><li><a href="#playerProfiles"><span>Players</span></a></li></ul>');
			$('#informationPane').append('<div id="PreFlop">'+$preFlop+'</div>');
			$('#informationPane').append('<div id="Flop"><p class="streetName">Flop</p>'+$Flop+'</div>');
			$('#informationPane').append('<div id="Turn"><p class="streetName">Turn</p>'+$Turn+'</div>');
			$('#informationPane').append('<div id="River"><p class="streetName">River</p>'+$River+'</div>');
			$('#informationPane').append('<div id="Showdown"><p class="streetName">Showdown</p>'+$Showdown+'</div>');
			$('#playerProfiles').append('<div id="Showdown"><p class="streetName">Player Profiles</p>'+$playerProfiles+'</div>');

			if($handID=='680417716'){
			$('#informationPane').append('<div id="comments"><h2><strong>Comments On This Hand</strong></h2<div id="handComment1234" class="comment"> <p>If you had hit a straight with runner runner against me I would have gone beserk!</p><div class="comment-author">RonHeywood 02 March 2009 22:18 <a href="#">report</a></div></div></div>');
			}
			
			$('#informationPane').tabs();
			if($Flop==null){$('#informationPane').tabs('disable',1)};
			//console.debug($Turn==null);
			if($Turn==null){$('#informationPane').tabs('disable',2)};
			if($River==null){$('#informationPane').tabs('disable',3)};
			//console.debug(e);
			//$('#informationPane').css('top',(e.pageY-100)+'px');
	}
	
	$('document').ready(function(){
		$('.handInfo a').bind('click',function(e){
			$handID = $(this).parents('.hand').attr('id');
			showHandData($handID);
			return false;
		})
		
		$('.handHistory').before('<div id="handNav"></div><p style="clear: both;">&nbsp;</p>') 
		.cycle({ 
			fx:    'scrollLeft',
			speed:  'fast', 
			timeout: 0, 
			pager:  '#handNav',
			after:   function(){
				showHandData($(this).attr('id'))
				//console.debug($(this).attr('id'));
			}
		});
	});
</script>
</head>

<body>


<?php
	require('models/hand_analyser.php');
	$handAnalyser = new HandAnalyser();
		$handAnalyser->historyFolder = 'userfiles';
		$handAnalyser->userName = $_SESSION['username'];
		$handAnalyser->handDate = (isset($_REQUEST['date'])) ? $_REQUEST['date'] : date('Ymd');
		$handAnalyser->tableName = (isset($_REQUEST['table'])) ? stripslashes($_REQUEST['table']) : '';

		$handAnalyser->processHandFile();
		
		//echo '<pre>'; print_r($handAnalyser); echo '</pre>';
		?>
    <p><a href="index.php?date=<?php echo $handAnalyser->handDate;?>">Back to Calendar</a></p>
	
	<h1>User: <?php echo $handAnalyser->userName;?></h1>
	<div id="stats">
	<?php $stats = $handAnalyser->tableStats;
	//AF = (Raise % + Bet %) / Call % 
	//print_r($stats['agression']);
	
	
	$afTotal = $stats['agression']['raise']+$stats['agression']['bet']+$stats['agression']['call'];
	$afTotal  = ($afTotal == 0) ? 1: $afTotal;
	$raisePCT = ($stats['agression']['raise']/$afTotal)*100;
	$betPCT = ($stats['agression']['bet']/$afTotal)*100;
	$callPCT = ($stats['agression']['call']/$afTotal)*100;
	
	$callPCT =($callPCT==0) ? 1 : $callPCT;
	
	@$af = ($raisePCT + $betPCT) / $callPCT;
	//echo ($stats['vpp']/$stats['handsSeen']*100);
    				echo( "<div class=\"stats played\">Hands Seen: {$stats['handsSeen']} Played: {$stats['played']} Won: {$stats['won']} Lost: {$stats['lost']} BB: {$stats['bigBlind']} SB: {$stats['smallBlind']} VPP: {$stats['vpp']} (".number_format(($stats['vpp']/$stats['handsSeen'])*100)."%) PFR: {$stats['pfr']} (".number_format($stats['pfr']/$stats['handsSeen']*100)."%) AF: $af WTSD: {$stats['wtsd']}  WTSDW: {$stats['wtsdw']}</div>" );
					
				echo( "<div class=\"stats value\">Total Action: {$stats['totalAction']} Won: {$stats['totalWon']} Lost: {$stats['totalLost']}  BB: {$stats['totalBigBlnd']} SB: {$stats['totalSmallBlnd']} Return: {$stats['roi']} (".number_format($stats['roiPercent'])."%)</div>");
                
                if(isset($stats['sttPosition']) && $stats['sttPosition']!=''){
			echo( '<div>Single Table Tournament Finishing Position = '.$stats['sttPosition'].'</div>' );
				}
				
				?>
</div>
	
	
<div id="dataWrapper">
	<div class="handHistory">
		<?php $handAnalyser->printHandList(); ?>
	</div>

	<div id="informationPane">
    </div>
    <br style="clear:both;"/>
    <?php if($_REQUEST['table']=='STT %238695671.txt'){ ?>
    <div id="comments"><h2><strong>Comments On This Game</strong></h2>
    	<div id="gameComment1234" class="comment">
        	<p>You re-raised he flop with air on the bubble?? Why?</p>
            <div class="comment-author">RonHeywood 02 March 2009 22:28 <a href="#">report</a></div>
        </div>
    </div>
    <?php } ?>
</div>
<?php include('googleTracking.php');?>
</body>
</html>
